package com.lee.dutylower.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.lee.dutylower.R;
import com.lee.dutylower.db.greenEntity.Squad;

import java.util.List;

/**
 * Created by lijie on 2017/4/27.
 */

public class RVAdapter extends RecyclerView.Adapter<RVAdapter.ViewHolder> {
    private List values;
    public RVAdapter(List values) {
        this.values = values;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v = View.inflate(parent.getContext(), R.layout.layout_setting_item,null);
        ViewHolder holder = new ViewHolder(v);
        return holder;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        Squad squad = (Squad) values.get(position);
        String s = squad.getSquadName();
        s = s.replace("\n","").replace("\r","").trim();
        holder.textView.setText(s);
    }

    @Override
    public int getItemCount() {
        return values.size();
    }

    class ViewHolder extends RecyclerView.ViewHolder{
        TextView textView;
        public ViewHolder(View itemView) {
            super(itemView);
            textView = (TextView) itemView.findViewById(R.id.tv_setting_item);
        }
    }
}
